import React, { Component } from 'react';

localStorage.setItem('userName', '吴大勋')

class Footer extends Component {
  render () {
    return (
      <footer>
        Copyright 2011-2022 北京千锋互联科技有限公司 京ICP备12003911号-3 
      </footer>
    )
  }
}

class Child1 extends Component {
  componentDidMount () {
    console.log(localStorage.getItem('userName'))
  }
  render () {
    return (
      <div>
        <h1>child1</h1>
        <Footer />
      </div>
    )
  }
}
class Child2 extends Component {
  componentDidMount () {
    console.log(localStorage.getItem('userName'))
  }
  render () {
    return (
      <div>
        <h1>child2</h1>
        <Footer />
      </div>
    )
  }
}
class App extends Component {
  render() {
    return (
      <div>
        <Child1 />
        <hr />
        <Child2 />
      </div>
    );
  }
}

export default App;